package com.punai.customer.controller;

import com.punai.common.annotation.Log;
import com.punai.common.core.controller.BaseController;
import com.punai.common.core.domain.AjaxResult;
import com.punai.common.core.page.TableDataInfo;
import com.punai.common.enums.BusinessType;
import com.punai.customer.domain.CusMechanicalStaItem;
import com.punai.customer.service.ICusMechanicalStaItemService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 机械费用项Controller
 * 
 * @author zxw_
 * @date 2023-02-02
 */
@RestController
@RequestMapping("/cus/cusMechanicalStaItem")
public class CusMechanicalStaItemController extends BaseController
{
    @Autowired
    private ICusMechanicalStaItemService cusMechanicalStaItemService;

    /**
     * 查询机械费用项列表
     */
    @PreAuthorize("@ss.hasPermi('cus:cusMechanicalStaItem:list')")
    @GetMapping("/list")
    public TableDataInfo list(CusMechanicalStaItem cusMechanicalStaItem)
    {
        startPage();
        List<CusMechanicalStaItem> list = cusMechanicalStaItemService.selectCusMechanicalStaItemList(cusMechanicalStaItem);
        return getDataTable(list);
    }

    /**
     * 获取机械费用项详细信息
     */
    @PreAuthorize("@ss.hasPermi('cus:cusMechanicalStaItem:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return AjaxResult.success(cusMechanicalStaItemService.selectCusMechanicalStaItemById(id));
    }

    /**
     * 新增机械费用项
     */
    @PreAuthorize("@ss.hasPermi('cus:cusMechanicalStaItem:add')")
    @Log(title = "机械费用项", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody CusMechanicalStaItem cusMechanicalStaItem)
    {
        return toAjax(cusMechanicalStaItemService.insertCusMechanicalStaItem(cusMechanicalStaItem));
    }

    /**
     * 修改机械费用项
     */
    @PreAuthorize("@ss.hasPermi('cus:cusMechanicalStaItem:edit')")
    @Log(title = "机械费用项", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody CusMechanicalStaItem cusMechanicalStaItem)
    {
        return toAjax(cusMechanicalStaItemService.updateCusMechanicalStaItem(cusMechanicalStaItem));
    }

    /**
     * 删除机械费用项
     */
    @PreAuthorize("@ss.hasPermi('cus:cusMechanicalStaItem:remove')")
    @Log(title = "机械费用项", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids)
    {
        return toAjax(cusMechanicalStaItemService.deleteCusMechanicalStaItemByIds(ids));
    }
}
